import pygame
from random import randint
import random

class map():
    def __init__(self):
        self.geoms = []
        self.x = 0
        self.y = 0
        self.z = 0
        self.vx = 0
        self.vy = 0
        self.vz = 0
        self.ax = 0
        self.ay = 0
        self.az = 0
        self.a_max = .6
        self.v_max = 6
        self.color = (0,0,0)

    def generate(self):
        for i in range(0,20):
            for j in range(0,15):
                self.geoms.append(pygame.Rect(i*100,j*100,100,5))
                self.geoms.append(pygame.Rect(i*100,j*100,5,100))

        for i in range(400):
            self.geoms.remove(random.choice(self.geoms))

    def colorshift(self):
        self.ax = max(min(random.randint(-1, 1)+self.ax, self.a_max), -self.a_max)
        self.ay = max(min(random.randint(-1, 1)+self.ay, self.a_max), -self.a_max)
        self.az = max(min(random.randint(-1, 1)+self.az, self.a_max), -self.a_max)
        self.vx = max(min(self.vx+self.ax, self.v_max), -self.v_max)
        self.vy = max(min(self.vy+self.ay, self.v_max), -self.v_max)
        self.vz = max(min(self.vz+self.az, self.v_max), -self.v_max)
        self.x = (self.x + self.vx)%255
        self.y = (self.y + self.vy)%255
        self.z = (self.z + self.vz)%255
        self.color = (self.x,self.y,self.z)

